package 设计mos.BridgePattern;

import java.awt.*;

/**
 * @作者：xie
 * @时间：2022/10/11 14:08
 *
 * 桥接模式
 */

public class main {
    public static void main(String[] args) {
        Product A = new ProductA();
        Color red = new Red();
        A.setName("1");
        A.setColor(red);
        A.Operation();
    }
}

abstract class Product{
    private String name;
    protected Color color;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setColor(Color color) {
        this.color = color;
    }

    public abstract void Operation();
}

class ProductA extends Product{

    @Override
    public void Operation() {
        color.OperationImp(this.getName());
    }
}

interface Color{
    public void OperationImp(String name);

}

class Red implements Color{

    @Override
    public void OperationImp(String name) {
        System.out.println(name+":hon");
    }
}

class Blue implements Color{

    @Override
    public void OperationImp(String name) {
        System.out.println(name+":lan");
    }
}

